//
//  MineTableViewCell.swift
//  ezyform
//
//  Created by Moennig Q on 31/8/2022.
//  Copyright © 2022 Client.Solution Pty Ltd. All rights reserved.
//

import UIKit
import SnapKit
class MeTableViewCell: UITableViewCell {
    let leftImageView = UIImageView()
    let titleLabel = ContentLabel(R.font.interMedium(size: 15))
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setUpviews()
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        
    }
    func setUpviews(){
        self.contentView.backgroundColor = .white
        //
        let backView = UIView()
        backView.drawCorner(byRoundingCorners: .allCorners,radii: 6,backColorHexStr: Constant.SystemBackColor)
        self.contentView.addSubview(backView)
        backView.snp.makeConstraints { make in
            make.left.equalTo(20)
            make.right.equalTo(-20)
            make.top.equalTo(16)
            make.height.greaterThanOrEqualTo(0)
            make.bottom.equalToSuperview()
        }
        //left image
        backView.addSubview(leftImageView)
        leftImageView.snp.makeConstraints { make in
            make.left.equalTo(12)
            make.height.width.equalTo(24)
            make.centerY.equalToSuperview()
        }
        //title label
        backView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.top.equalTo(15)
            make.left.equalTo(leftImageView.snp.right).offset(12)
            make.width.height.greaterThanOrEqualTo(0)
            make.bottom.equalTo(-15)
        }
        //right image view
        let moreImageView = ViewFactory.shared.generateMoreImageView()
        backView.addSubview(moreImageView)
        moreImageView.snp.makeConstraints { make in
            make.height.width.equalTo(24)
            make.centerY.equalToSuperview()
            make.right.equalTo(-12)
        }
        //line view
        let lineView = View(hexStr: Constant.SystemBackColor)
        backView.addSubview(lineView)
        lineView.snp.makeConstraints { make in
            make.left.equalTo(titleLabel)
            make.right.equalToSuperview()
            make.height.equalTo(1)
            make.bottom.equalToSuperview()
        }
    }
    func setData(_ menuType: MeMenuType){
        switch menuType {
        case .profile:
            self.leftImageView.image = R.image.meMyInformation()
            self.titleLabel.text = R.string.localizable.profile()
        case .rewards:
            self.leftImageView.image = R.image.meInstallerPoints()
            self.titleLabel.text = R.string.localizable.rewards()
//        case .loginMethod:
//            self.leftImageView.image = R.image.meLoginmethod()
//            self.titleLabel.text = R.string.localizable.loginMethod()
        case .settings:
            self.leftImageView.image = R.image.meSettings()
            self.titleLabel.text = R.string.localizable.settings()
        default:
            break
        }
    }
}
